#include "stdafx.h"
#include "TimerUtil.h"

#include "Util.h"


namespace TimerUtil
{
    ExportXSkinLib UINT_PTR SetTimer(IXTimer* pTimer, UINT uElapse, void* pData)
    {
        UINT_PTR uId = -1;
        XPtr<IXTimerMgr> pTimerMgr;
        if(SUCCEEDED(Util::CreateObject(&pTimerMgr)))
        {
            uId = pTimerMgr->SetTimer(pTimer, uElapse, pData);
        }
        return uId;
    }

    ExportXSkinLib UINT_PTR SetAsyncTimer(IXTimer* pTimer, UINT uElapse, void* pData)
    {
        UINT_PTR uId = -1;
        XPtr<IXTimerMgr> pTimerMgr;
        if(SUCCEEDED(Util::CreateObject(&pTimerMgr)))
        {
            uId = pTimerMgr->SetAsyncTimer(pTimer, uElapse, pData);
        }
        return uId;
    }

    ExportXSkinLib UINT_PTR ResetTimer(UINT_PTR uId, UINT uElapse)
    {
        UINT_PTR uResult = -1;
        XPtr<IXTimerMgr> pTimerMgr;
        if(SUCCEEDED(Util::CreateObject(&pTimerMgr)))
        {
            uResult = pTimerMgr->ResetTimer(uId, uElapse);
        }
        return uResult;
    }

    ExportXSkinLib void* ResetTimer(UINT_PTR uId, void* pData)
    {
        void* pResult = NULL;
        XPtr<IXTimerMgr> pTimerMgr;
        if(SUCCEEDED(Util::CreateObject(&pTimerMgr)))
        {
            pResult = pTimerMgr->ResetTimer(uId, pData);
        }
        return pResult;
    }

    ExportXSkinLib IXTimer* ResetTimer(UINT_PTR uId, IXTimer* pTimer)
    {
        IXTimer* pResult = NULL;
        XPtr<IXTimerMgr> pTimerMgr;
        if(SUCCEEDED(Util::CreateObject(&pTimerMgr)))
        {
            pResult = pTimerMgr->ResetTimer(uId, pTimer);
        }
        return pResult;
    }

    ExportXSkinLib BOOL KillTimer(UINT_PTR uId)
    {
        BOOL bResult = FALSE;
        XPtr<IXTimerMgr> pTimerMgr;
        if(SUCCEEDED(Util::CreateObject(&pTimerMgr)))
        {
            bResult = pTimerMgr->KillTimer(uId);
        }
        return bResult;
    }

    ExportXSkinLib BOOL KillTimer(IXTimer* pTimer)
    {
        BOOL bResult = FALSE;
        XPtr<IXTimerMgr> pTimerMgr;
        if(SUCCEEDED(Util::CreateObject(&pTimerMgr)))
        {
            bResult = pTimerMgr->KillTimer(pTimer);
        }
        return bResult;
    }
}